package com.basic.hellorabbit;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
* @Description:    消息生产者/提供者
* @Author:         Joe
* @CreateDate:     2020/3/11 23:50
*/
@Component
public class RabbitProvider {

    @Autowired
    private AmqpTemplate amqpTemplate;

    public void send(){
        String content = "你好！"+ new Date();
        System.out.println("生产者:" + content);
        amqpTemplate.convertAndSend("TestRabbitMQ",content);
    }
}
